<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<jsp:include page="../frame/header.jsp"></jsp:include>

<title>添加子分类</title>
<style>
#picture{
	position:absolute;
	left:600px;
	top:200px;
}
</style>

</head>

<body>
	<div class="container-fluid">
		<div class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">生活信息</a> <span class="divider">/</span></li>
					<li><a href="#">信息分类</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						生活信息分类管理---添加子分类
					</h2>
					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<form id="myform" class="form-horizontal" method="post" action="<c:url value="/admin/live/sort" />">
						<fieldset>
							<input type="hidden" name="sortId" value="${liveSort.sortId }">
							
							<div class="control-group">
								<label class="control-label" for="sortParent">上级分类</label>
								<div class="controls">
									<input class="input-xlarge"  type="text"
										value="${parentSort.sortName }" readonly>
								</div>
								<input type="hidden" name="sortParent" id="sortParent" value="${parentSort.sortId }">
							</div>
							
							<div class="control-group">
								<label class="control-label" for="sortName">分类名称</label>
								<div class="controls">
									<input class="input-xlarge" id="sortName" name="sortName" type="text"
										value="${liveSort.sortName }" maxlength="50" check-type="required" required-message="请输入分类名称">
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="funCode">功能分类</label>
								<div class="controls">
									<select id="funCode" class="input-xlarge" name="funCode">
										<option value="0" <c:if test="${liveSort.funCode == 0}">selected</c:if> >仅作为目录分类</option>
										<option value="1" <c:if test="${liveSort.funCode == 1}">selected</c:if> >常用信息</option>
										<option value="2" <c:if test="${liveSort.funCode == 2}">selected</c:if> >地址类信息</option>
										<option value="3" <c:if test="${liveSort.funCode == 3}">selected</c:if> >综合类信息</option>
										<option value="4" <c:if test="${liveSort.funCode == 4}">selected</c:if> >球赛类信息</option>
									</select>
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="sortNum">显示顺序</label>
								<div class="controls">
									<input class="input-xlarge" id="sortNum" name="sortNum" type="text"
										value="${liveSort.sortNum }">
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="fileInput">个性图标</label>
								<div class="controls">
									<input class="input-file uniform_on" name="file"
										id="userHeader" type="file"> <input type="button" class="btn btn-success"
										value="upload" onclick="return ajaxFileUpload();">
								</div>
								<img id="loading" class="hide" src="<c:url value="/resources/img/ajax-loader-6.gif"/>">
								<img id="picture" src='<c:url value="/resources/fileupload/${liveSort.sortPic }"/>' width="100" height="100">
								<input type="hidden" name="sortPic" id="sortPic" value="${liveSort.sortPic }">
							</div>
							
							<div class="control-group">
								<label class="control-label" for="sortDesc">详细描述 </label>
								<div class="controls">
									<textarea rows="6" id="sortDesc" name="sortDesc" class="input-xxlarge">${liveSort.sortDesc }</textarea>
								</div>
							</div>
							
							<div class="form-actions">
								<button id="saveBtn" type="button" class="btn btn-primary">保存</button>
								<button id="cancelBtn" type="button" class="btn">返回</button>
							</div>
						</fieldset>
					</form>

				</div>
			</div>
			<!--/span-->

		</div>
	</div>
	<!--/row-->
</body>

<jsp:include page="../frame/scripts.jsp"></jsp:include>
<script type="text/javascript">
$(document).ready(function(){
	
	$("#myform").validation();
	
	//返回上一页
	$('#cancelBtn').click(function(){
		window.location.href = '<c:url value="/admin/live/live_sort" />';	
	});
	
	//保存
	$('#saveBtn').click(function(){
		$("#myform").submit();
	})
	
})

	//上传图片
	function ajaxFileUpload(){
		
		$("#loading").ajaxStart(function(){
			//开始上传文件时显示一个图片
			$(this).show();
		}).ajaxComplete(function(){
			//文件上传完成将图片隐藏起来
			$(this).hide();
		});
		
		$.ajaxFileUpload({
			url:'<c:url value="/fileupload"/>',//用于文件上传的服务器端请求地址
			secureuri:false,//一般设置为false
			fileElementId:'userHeader',//文件上传空间的id属性  <input type="file" id="file" name="file" />
			dataType: 'JSON',//返回值类型 一般设置为json(大写)
			success: function (data, status){
				var image = DOMAIN + '/resources/fileupload/'+$(data).html();
				$("#picture").attr('src',image).show();
				$("input[name='sortPic']").val($(data).html());
			},
			error: function (data, status, e){
				alert(e);
			}	
		})
		
		return false;
	}
</script>